package com.wly.ui.common
{
	import com.wly.control.common.BaseControl;
	
	import flash.display.Sprite;
	
	public class BaseSprite extends Sprite implements IBaseUI
	{
		protected var _ctrl:BaseControl;
		
		public function BaseSprite()
		{
			super();
		}
		
		protected function onControlAttach():void
		{
			
		}
		
		protected function onControlDeattach():void
		{
			
		}
		
		public function attachUIControl(ctrl:BaseControl):void
		{
			deattachUIControl();
			_ctrl = ctrl;
			if(_ctrl)
			{
				onControlAttach();
				_ctrl.attachUI(this);
			}
		}
		
		public function deattachUIControl():void
		{
			if(_ctrl)
			{
				onControlDeattach();
				_ctrl.deattachUI();
				_ctrl = null;
			}
		}
	}
}